<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/23/0023
 * Time: 13:36
 */

namespace App\Http\Controllers\Api\Admin;

use Illuminate\Support\Facades\Storage;
use App\Http\Controllers\Api\Controller;

class ImagesController extends Controller
{
    public function store(){
        $disk = Storage::disk('qiniu'); //使用七牛云上传
        $time = date('Y-m-d');
        $filename = $disk->put($time, request()->file('file'));//上传
        if(!$filename) {
            return response()->json(['code' => 1, 'msg' => '上传失败']);
        }
        $img_url = $disk->getDriver()->downloadUrl($filename); //获取下载链接
        return response()->json(['code' => 0, 'msg' => '上传成功', 'src' => $img_url]);
    }
}